package cn.flying.cloud.file.api.dubbo;

import javax.annotation.Resource;

import java.io.IOException;

import org.apache.dubbo.config.annotation.DubboService;

import cn.flying.cloud.file.api.FileServiceApi;
import cn.flying.cloud.file.core.service.FileService;
import cn.flying.cloud.file.model.FileRequest;

/**
 * 文件服务接口
 *
 * @author: admin
 * @date: 2025年03月25日 23:19
 * @version: 1.0
 */
@DubboService
public class FileApiService implements FileServiceApi {
    @Resource
    private FileService fileService;

    /**
     * 上传文件
     *
     * @param request
     * @return
     * @throws IOException
     */
    @Override
    public String upload(FileRequest request) {
        return fileService.uploadFile(request);
    }

    /**
     * 下载文件
     *
     * @param bucket
     * @param filename
     */
    @Override
    public byte[] download(String bucket, String filename) {
        return fileService.download(bucket, filename);
    }

    /**
     * 获取文件URL
     *
     * @param bucket
     * @param filename
     * @return
     */
    @Override
    public String getObjectUrl(String bucket, String filename) {
        return fileService.getObjectUrl(bucket, filename);
    }

}
